package com.jkd.service.impl;

import com.jkd.mapper.DisciplineMapper;
import com.jkd.model.pojo.Discipline;
import com.jkd.service.IDisciplineService;
import com.jkd.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class DisciplineServiceImpl implements IDisciplineService {
    @Override
    public List<Discipline> selectAll() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        DisciplineMapper disciplineMapper = sqlSession.getMapper(DisciplineMapper.class);
        List<Discipline> list  =  disciplineMapper.selectAll();
        MyBatisUtil.closeSqlSession(sqlSession);
        return list;
    }

    @Override
    public Discipline selectById(Integer disciplineId) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        DisciplineMapper disciplineMapper = sqlSession.getMapper(DisciplineMapper.class);
        Discipline discipline= disciplineMapper.selectById(disciplineId);
        MyBatisUtil.closeSqlSession(sqlSession);
        return  discipline;
    }
}
